import pygtk
pygtk.require('2.0')
import gtk
import values
import os

class Vol:
        def set_val(self, num, banda): 
                a = os.popen("amixer -D equal sset '"+str(banda)+"' "+str(num))
                a.close()
		#print "amixer -D equal sset '"+str(banda)+"' "+str(num)
		

class Channel:

	def __init__(self, id, l_u, l_b, r_u, r_b, table):
		self.adjustment_channel = gtk.Adjustment(value=0, lower=0, upper=100, step_incr=1, page_incr=0, page_size=0)
                #valor = values.Values(id) 
                #self.adjustment_channel.set_value(valor.valor())
                self.channel = gtk.VScale(self.adjustment_channel)
                self.channel.set_value_pos(gtk.POS_LEFT)
		self.channel.set_inverted(True)
                self.channel.set_digits(0)
                self.channel.show()
                self.channel.set_update_policy(gtk.UPDATE_CONTINUOUS)
                self.channel.set_adjustment(self.adjustment_channel)
                self.channel.connect("value_changed", self.volume_change_channel, self.adjustment_channel, id) 
                table.attach(self.channel, l_u, l_b, r_u, r_b)
		label = gtk.Label(id)
		label.show()
		table.attach(label, l_u, l_b, 0, 1)
		table.show()
		self.vol = Vol()

	def volume_change_channel(self, func, value, banda):
		self.channel.set_adjustment(value)
		self.vol.set_val(value.get_value(), banda)
	
	def getVolume(self):
		print self.adjustment_channel.get_value()

	def setVolume(self, id, value):
		self.vol.set_val(id, value)
		self.adjustment_channel.set_value(value)


